import {getSharePrintOrder} from '@/api/order.js'
export default {
	data() {
		return {
			orderIds:'',
			imageUrl: '',
			shareTitle: '',
			sharePath: ''
		}
	},
	onLoad: function() {
		wx.showShareMenu({
			withShareTicket: true,
			menus: ["shareAppMessage"]// "shareTimeline"
		})
	},
	// 分享好友
	onShareAppMessage(res) {
		console.log(res,'onShareAppMessage')
		let that = this;
		let imageUrl = that.imageUrl || '';
		if (res.from === 'button') {
			console.log('button')
			//这块需要传参，不然链接地址进去获取不到数据
			let path = `/` + that.$scope.route + `?id=` + that.orderIds//that.$scope.options.item;
			console.log(path,'分享给好友',that.orderIds)
			that.share()
			return {
				title: that.shareTitle,
				path: path,
				imageUrl: imageUrl
			};
		}
		if (res.from === 'menu') {
			console.log('menu')
			return {
				title: '2222222222222商通线上商城',
				path: '/pages/tabBarPro/index/index',
				imageUrl: imageUrl
			};
		}
	},
	// 分享到朋友圈
	// onShareTimeline() {
	// 	return {
	// 		title: '6666666666商通线上商城',
	// 		path: '/pages/index/index',
	// 		imageUrl: 'https://cdn.uviewui.com/uview/swiper/1.jpg'
	// 	};
	// },
	methods: {
		share(){
			getSharePrintOrder({orderId:this.orderIds})
		}
	}
}